from PyQt5.QtWidgets import QProgressBar
from PyQt5.QtGui import QPixmap
from PyQt5.QtGui import QMouseEvent

# 设计动态进度条?
class ProgressMouseMoveBar(QProgressBar):
    """一个简单的动态的进度条

    当鼠标点住并移动的时候改变进度条的值
    """    
    isPress: bool = False
    
    def __init__(self, parent=None):
        super(ProgressMouseMoveBar, self).__init__(parent)
        
    def mousePressEvent(self, event: QMouseEvent):
        self.isPress = True
    
    def mouseReleaseEvent(self, event):
        self.isPress = False
        
    def mouseMoveEvent(self, event: QMouseEvent) -> None:
        # print("Move")
        if self.isPress == True:
            value = ((event.x() / self.width()) * 100)
            self.setValue(value)
            pass
        return super().mouseMoveEvent(event)
